home *** CD-ROM | disk | FTP | other *** search
- ##=====================================================================
- ## Sense client capabilities
- ##=====================================================================
-
- proc dwSenseClientCapabilities {} {
-
- ## NOTE: can't get user-agent field in CGI mode
- set UserAgent [dwGetHttpField "user-agent"]
-
- set Display "TTY"
- set PlatForm "unknown"
- set Frames "0"
- set Agent "unknown"
- set MajorVer "unknown"
- set MinorVer "unknown"
- set Tables "1"
- set Entities "1"
- set RelativeURLs "1"
- # Pretty much assured to be true....
- set BrokenCharset "1"
-
- # Ladder for detecting platform
- if {[string match "*SunOS*" $UserAgent] == 1} {
- set PlatForm "unix"
- }
-
- # Ladder to detect the display type
- # - X11 Clients are assumes to be Unix based
- if {[string match "*X11*" $UserAgent] == 1} {
- set PlatForm "unix"
- set Display "X11"
- }
- if {[string match "*X Window System*" $UserAgent] == 1} {
- set PlatForm "unix"
- set Display "X11"
- }
-
- # Break up the user-agent field
- set vpos [string first "/" $UserAgent]
- set Agent [string trim [string range $UserAgent 0 [expr $vpos - 1]]]
- set version [string range $UserAgent [incr vpos] end]
- set version [string range $version 0 [string first " " $version]]
- set vpos [string first "." $version]
- set MajorVer [string trim [string range $version 0 [expr $vpos - 1]]]
- set MinorVer [string trim [string range $version [incr vpos] end]]
- set MinorVer [string trim [string range $MinorVer 0 1]]
-
- # Check for frames support
- if {[string match "Mozilla*" $Agent] == 1} {
- if {$MajorVer >= 2} {
- set Frames 1
- }
- if {$MajorVer < 2} {
- set Tables 0
- set Entities 0
- }
- } elseif {[string match "Spyglass*" $Agent] == 1} {
- if {$MajorVer == 2} {
- if {$MinorVer >= 11} {
- set Frames 0
- set Tables 1
- set Entities 1
- set RelativeURLs 1
- }
- }
- } elseif {[string match "Multilingual Mosaic*" $Agent] == 1} {
- set Frames 0
- set Tables 1
- set Entities 1
- set RelativeURLs 1
- } elseif {[string match "*Mosaic*" $Agent] == 1} {
- if {$MajorVer == 2} {
- if {$MinorVer < 7} {
- set Frames 0
- set Tables 0
- set Entities 0
- set RelativeURLs 0
- }
- }
- } elseif {[string match "*Lynx*" $Agent] == 1} {
- set Frames 0
- set Tables 0
- set Entities 0
- set RelativeURLs 0
- }
-
- # Build up the capabilities list
- lappend capabilities [list "platform" $PlatForm]
- lappend capabilities [list "display" $Display]
- lappend capabilities [list "frames" $Frames]
- lappend capabilities [list "agent" $Agent]
- lappend capabilities [list "major" $MajorVer]
- lappend capabilities [list "minor" $MinorVer]
- lappend capabilities [list "tables" $Tables]
- lappend capabilities [list "entities" $Entities]
- lappend capabilities [list "relative-urls" $RelativeURLs]
- lappend capabilities [list "broken_charset" $BrokenCharset]
-
- return $capabilities
- }
-
-
- proc dwQueryCapability {name caplist} {
- foreach item $caplist {
- if {[lsearch $item $name] != -1} {
- return [lindex $item 1]
- }
- }
- return ""
- }
-
-
- ##======================================================================
- ## Map from the ECM name to the legal IANA value
- ##======================================================================
-
- proc dwMapEcmToIANA {encoding} {
- switch -exact -- $encoding {
- "C" { return "iso-8859-1" }
- "ja_euc" { return "euc-jp" }
- "ja_sjis" { return "shift-jis" }
- "utf8" { return "UNICODE-1-1-UTF-8"}
- }
- }
-